package com.example.demo.service.user;

import com.example.demo.commom.PasswordUtils;
import com.example.demo.commom.TokenUtil;
import com.example.demo.dto.user.class_info.ClassInfoDto;
import com.example.demo.dto.user.login.ULoginDto;
import com.example.demo.dto.user.reg.PRegDto;
import com.example.demo.entity.user.ClassInfo;
import com.example.demo.entity.user.Parent;
import com.example.demo.mapper.user.ClassMapper;
import com.example.demo.mapper.user.ParentMapper;
import com.example.demo.mapper.user.StudentMapper;
import com.example.demo.vo.user.LoginVo;
import com.example.demo.vo.user.UserInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:龙宝
 * Date:2023-03-31
 * Time:18:37
 */
@Service
public class ClassInfoService {
    @Autowired
    private ClassMapper classMapper;
    @Autowired
    private StudentMapper studentMapper;


    // 查看所有班级信息
    public List<ClassInfo> getClassAll(){
        return classMapper.getClassInfoAll();
    }

    // 修改学生的班级信息
    public Integer updateClass(String student_ids, Integer class_id){
        String[] ids = student_ids.split(",");
        int count = 0;
        for(String id : ids){
            count += studentMapper.updateStudentClassId(Integer.valueOf(id), class_id);
        }
        return count;
    }

    // 新增班级
    public Integer add(ClassInfoDto classInfoDto){
        return classMapper.addClass(classInfoDto);
    }
}
